#-*-coding:utf8-*-

import signal
import time
import platform


def signal_handler(signum,frame):
    print 'signal handler function...'
    print 'singal number = ',signum
    print 'signal frame  = ',frame

def windows_signal_example():
    signal.signal(signal.SIGINT,signal_handler)
    while True:
        time.sleep(2)
    '''
    try:
        while True:
            time.sleep(2)
    except KeyboardInterrupt as ki:
        print 'KeyboardInterrupt ... ',ki
        while True:
            time.sleep(2)
    '''

def linux_signal_example():
    signal.signal(signal.SIGINT,signal_handler)
    signal.pause()

if __name__=='__main__':
    print '*'*20,'start  test','*'*20
    if platform.system()=='Windows':
        windows_signal_example()
    elif platform.system()=='Linux':
        linux_signal_example()
    else:
        print 'other OS'
    print '*'*20,'end of test','*'*20


